package com.mzy.linear_struct.hot100.二叉树;

import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

/**
 * @Author: mizy3
 * @Date: 2024/08/20/下午7:58
 * @Description:
 */
public class Pro104二叉树的最大深度 {
    public int maxDepth(TreeNode root) {
        if(root == null) {
            return 0;
        }
        return Math.max(maxDepth(root.left) + 1, maxDepth(root.right) + 1);
    }

   /* public int maxDepth(TreeNode root) {
        Queue<TreeNode> queue = new LinkedList<>();
        queue.offer(root);
        int height = 0;
        while (!queue.isEmpty()) {
            int size = queue.size();
            while (size-- > 0) {
                TreeNode node = queue.poll();
                if (node.left != null) {
                    queue.offer(node.left);
                }
                if (node.right != null) {
                    queue.offer(node.right);
                }
            }
            height++;
        }
        return height;
    }*/
}
